package com.ktjy.pojo.order;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ktjy.pojo.goods.Product;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * 订单
 *
 * @author LILIBO
 * @since 2023-04-25
 */
@Tag(name = "订单", description = "订单数据")
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("`order`")
public class Order implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 销售订单ID
     */
    @Schema(description = "销售订单ID")
    @TableId(type = IdType.ASSIGN_ID) // 使用雪花算法生成ID
    private Long id;

    /**
     * 订单号 例如: YY202304161813
     */
    @Schema(description = "订单号 例如: YY202304161813")
    private String orderNo;

    /**
     * 下单时间
     */
    @Schema(description = "下单时间")
    private String orderTime;

    /**
     * 订单金额
     */
    @Schema(description = "订单金额")
    private Double orderCost;

    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remark;

    /**
     * 支付状态 0:未支付;1:已支付
     */
    @Schema(description = "支付状态 0:未支付;1:已支付", allowableValues = {"0", "1"}, example = "0")
    private Integer payStatus;

    /**
     * 状态 0:正在处理;1:已完成
     */
    @Schema(description = "状态 0:正在处理;1:已完成")
    private Integer status;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private String createTime;

    /**
     * 修改时间
     */
    @Schema(description = "修改时间")
    private String modifyTime;

    /**
     * 该订单的商品列表
     */
    @Schema(description = "修改时间")
    @TableField(exist = false) // 忽略此字段
    private List<Product> products;

    /**
     * 订单
     */
    public Order(String orderNo, String orderTime, Double orderCost, String remark, Integer payStatus, Integer status, String createTime, String modifyTime) {
        this.orderNo = orderNo;
        this.orderTime = orderTime;
        this.orderCost = orderCost;
        this.remark = remark;
        this.payStatus = payStatus;
        this.status = status;
        this.createTime = createTime;
        this.modifyTime = modifyTime;
    }

}
